127B - Canvas Frames - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
l = 105
cnt = [0] * l
for i in a:
    cnt[i] += 1
c = 0
for i in cnt:
    c += i // 2
ans = c // 2
print(ans)

C++ Code:

#include <bits/stdc++.h>

using namespace std;

void Mon_on_da_code() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}


#define ll long long
#define   endl         "\n"
#define   lpi(n)       for(int i=0 ; i<(n) ; i++)
#define   lpj(n)       for(int j=0 ; j<(n) ; j++)
#define   all(v)      ((v).begin()),((v).end())
#define   allr(v)      ((v).rbegin()),((v).rend())
#define   pb           push_back
#define F first
#define S second
#define sz(x) int((x).size())
#define ui unsigned int
typedef vector<int> vi;
typedef vector<ll> vll;

void flow() {
    int n,q;
    int Freq1[101] = {0};
    cin>>n;
    lpi(n) cin>>q , Freq1[q]++;
    double st{};
    lpi(101){
        if(Freq1[i]>=4) {
            st += Freq1[i] / 4;
            Freq1[i] = Freq1[i] % 4;
        }
        if(Freq1[i]>1 and Freq1[i]<=3)
            st+=0.5;
    }
    cout<<int(st);


}

int main() {
    Mon_on_da_code();
    int tt = 1;
    //  cin >> tt;
    while (tt--) {
        flow();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1075B - Taxi drivers and Lyft
1562A - The Miracle and the Sleeper
1216A - Prefixes
1490C - Sum of Cubes
868A - Bark to Unlock
873B - Balanced Substring
1401D - Maximum Distributed Tree
1716C - Robot in a Hallway
1688B - Patchouli's Magical Talisman
99A - Help Far Away Kingdom
622B - The Time
1688C - Manipulating History
1169D - Good Triple
1675B - Make It Increasing
588A - Duff and Meat
1541B - Pleasant Pairs
1626B - Minor Reduction
1680A - Minimums and Maximums
1713A - Traveling Salesman Problem
1713B - Optimal Reduction
1710A - Color the Picture
1686B - Odd Subarrays
251A - Points on Line
427C - Checkposts
1159A - A pile of stones
508A - Pasha and Pixels
912A - Tricky Alchemy
1249A - Yet Another Dividing into Teams
1713C - Build Permutation
1699A - The Third Three Number Problem